package com.xty.itgroup.tech05tytex.Controller;

import com.xty.itgroup.tech05tytex.Databean.Bean02Customer;
import com.xty.itgroup.tech05tytex.Databean.Bean02CustomerTicket;
import com.xty.itgroup.tech05tytex.Logic.Logic02Customer;
import com.xty.itgroup.tech05tytex.Util.Result;
import com.xty.itgroup.tech05tytex.Util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "CustomerController", tags = "客户资料接口")
@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    private Logic02Customer customer;
    @ApiOperation(value = "添加客户", notes = "添加客户")
    @RequestMapping(value = "/addcustomer",method = RequestMethod.POST)
    public Result addCustomer(@RequestBody Bean02Customer c){
        customer.addCustomer(c);
        return ResultUtil.success();
    }
    @ApiOperation(value = "添加客户开票信息", notes = "添加开票信息")
    @RequestMapping(value = "/addcustomerticket",method = RequestMethod.POST)
    public Result addCustomerTicket(@RequestBody Bean02CustomerTicket ct){
        customer.addTicketInfo(ct);
        return ResultUtil.success();
    }
    @ApiOperation(value = "修改客户信息", notes = "修改客户")
    @RequestMapping(value = "/updatecustomer",method = RequestMethod.POST)
    public Result addCustomerTicket(@RequestBody Bean02Customer ct){
        customer.updateCustomer(ct);
        return ResultUtil.success();
    }
    @ApiOperation(value = "简易客户列表", notes = "只有名称和id")
    @RequestMapping(value = "/simplelist",method = RequestMethod.GET)
    public Result simpleCustomer(){
        return ResultUtil.success(customer.simpleListCustomer());
    }
    @ApiOperation(value = "客户列表", notes = "客户全部信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "customer_name", value = "客户名称模糊查询", required = true, dataType = "string"),
            @ApiImplicitParam(name = "customer_code", value = "客户代码模糊查询", required = true, dataType = "string"),
            @ApiImplicitParam(name = "customer_type", value = "客户类别", required = true, dataType = "int",example = "1")
    })
    @RequestMapping(value = "/listcustomer",method = RequestMethod.GET)
    public Result listCustomer(String customer_name,String customer_code,int customer_type){
        return ResultUtil.success(customer.listCustomer(customer_name, customer_code, customer_type));

    }
    @ApiOperation(value = "主键获取开票信息", notes = "开票信息")
    @ApiImplicitParam(name = "customer_id", value = "客户类别", required = true, dataType = "int",example = "1")
    @RequestMapping(value = "/listticketinfo",method = RequestMethod.GET)
    public Result listCustomer(int customer_id){
        return ResultUtil.success(customer.listCustomerTicket(customer_id));
    }
    @ApiOperation(value = "主键获取合同条款", notes = "合同条款")
    @ApiImplicitParam(name = "contract_id", value = "条款编号", required = true, dataType = "int",example = "1")
    @RequestMapping(value = "/listcaluse",method = RequestMethod.GET)
    public Result listClause(int contract_id){
        return ResultUtil.success(customer.getClause(contract_id));
    }
}
